<?php

namespace app\user\controller;

use app\common\service\FansService;
use app\user\validate\FansValidate;
use app\common\model\Fans;
use app\common\attributes\RandyValidate;
use app\common\attributes\Menu;
use think\annotation\Inject;
use think\response\Json;

class FansController  extends UserBaseController
{
    #[Inject]
    protected Fans $model ;

    #[Inject]
    protected  FansService $service ;

    #[menu('查看粉丝账号列表')]
    public function index(): Json
    {
         $data = $this->getParams();
         //当前是否为关联查询
         $this->relationSearch = true;
         //设置过滤方法
         $extendQueryHelper = $this->buildparams();
         $list = $this->service->getFansList($extendQueryHelper, $data);
         foreach ($list as $row) {

         }
         return $this->success($list);
    }
     #[menu('查看粉丝账号列表')]
       public function list(  ){
        $data = $this->getParams();
         //当前是否为关联查询
         $this->relationSearch = true;
         //设置过滤方法
          $extendQueryHelper = $this->buildparams();
          $extendQueryHelper->setIsPage(false);
          $list = $this->service->getFansList($extendQueryHelper, $data);
           foreach ($list as $row) {

           }
           return $this->success($list);
       }


    #[menu('查看粉丝账号详情')]
    #[RandyValidate(validate: FansValidate::class, scene: 'read')]
    public function read( $fans_id ): Json
    {
        $res = $this->service->getFansItem($fans_id);
        return $this->returnSuccess($res);
    }

    #[menu('删除粉丝账号')]
    #[RandyValidate(validate: FansValidate::class, scene: 'del')]
    public function del( $fans_id ):Json
    {
        $res = $this->service->delFansItem( $fans_id );
        return $this->returnSuccess($res);
    }

    #[menu('更新粉丝账号')]
    #[RandyValidate(validate: FansValidate::class, scene: 'update')]
    public function update( $fans_id ): \think\response\Json
    {
        $data = $this->getParams();
        $res = $this->service->setFansItem($fans_id ,$data);
        return $this->returnSuccess();
    }

    #[menu('新增粉丝账号')]
    #[RandyValidate(validate: FansValidate::class, scene: 'save')]
    public function save():Json
    {
        $data = $this->getParams();
        $res = $this->service->addFansItem($data);
        return $this->returnSuccess($res);
    }



}
